<template>
  <div class="whole">
    <div class="title01">
      <div class="titleFont">告警列表</div>
      <el-row class="input_area">
                <span>
                    <div class="font1">报警级别:</div>
                    <el-select v-model="value" placeholder="请选择">
                      <el-option
                          v-for="item in options"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value">
                      </el-option>
                    </el-select>
                </span>
                <span>
                    <div class="font1" >时间：</div>
                       <el-date-picker
                           v-model="value2"
                           type="daterange"
                           align="right"
                           unlink-panels
                           range-separator="至"
                           start-placeholder="开始日期"
                           end-placeholder="结束日期"
                           :picker-options="pickerOptions">
                       </el-date-picker>
                </span>
        <span class="input_areaButton2">
                    <el-button @click="handleQuery">查询</el-button>
        </span>
      </el-row>
    </div>
    <div class="main">

        <el-button  style="margin-top: 10px;margin-left:20px;text-align: center">批量生成工单</el-button>
        <el-button  style="margin-top: 10px;text-align: center">导出</el-button>

      <div class="table_area">
        <el-table
            ref="multipleTable"
          :data="tableData"
          :header-cell-style="{background: '#ecf8f9', color: '#606266'}"
          tooltip-effect="dark"
          style="width: 100%;"
          @selection-change="handleSelectionChange">
              <el-table-column
                  type="selection"
                  width="55">
              </el-table-column>
              <el-table-column
                  prop="alarmName"
                  label="报警名称"
                  width="200">
              </el-table-column>
              <el-table-column
                  prop="alarmDetail"
                  label="报警详情"
                  width="200">
              </el-table-column>
              <el-table-column
                  prop="alarmStaff"
                  label="报警联系人"
                  width="120">
              </el-table-column>
              <el-table-column
                  prop="alarmLevel"
                  label="报警级别"
                  width="120">
              </el-table-column>
              <el-table-column
                  prop="alarmMark"
                  label="处理标志"
                  width="120">
              </el-table-column>
              <el-table-column
                  label="报警时间"
                  width="120">
                <template slot-scope="scope">{{ scope.row.date }}</template>
              </el-table-column>
              <el-table-column
                  prop="action"
                  label="操作"
                  show-overflow-tooltip>
                <template slot-scope="scope">
                  <a :href="scope.row.url" target="_blank" class="buttonText">{{scope.row.url}}</a>
                </template>
              </el-table-column>
            </el-table>
      </div>
    </div>
  </div>
</template>

<script>

export default {
    name: 'AlarmList',
    data() {
      return {
        options: [{
          value: '选项1',
          label: '普通'
        }, {
          value: '选项2',
          label: '中级'
        }, {
          value: '选项3',
          label: '高级'
        }],
        value: '',
        pickerOptions: {
          shortcuts: [{
            text: '最近一周',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '最近一个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '最近三个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit('pick', [start, end]);
            }
          }]
        },
        value1: '',
        value2: '',
        tableData: [{
          date: '2016-05-03',
          alarmName: '告警1',
          alarmDetail:'详情',
          alarmStaff:'王工',
          alarmLevel:'中级',
          alarmMark:'进行中',
              action:'派发工单'
        }, {
          date: '2016-05-02',
          alarmName: '告警1',
          alarmDetail:'详情',
          alarmStaff:'王工',
          alarmLevel:'中级',
          alarmMark:'进行中',
          action:'派发工单'
        }, {
          date: '2016-05-04',
          alarmName: '告警1',
          alarmDetail:'详情',
          alarmStaff:'王工',
          alarmLevel:'中级',
          alarmMark:'进行中',
          action:'派发工单'
        }, {
          date: '2016-05-01',
          alarmName: '告警1',
          alarmDetail:'详情',
          alarmStaff:'王工',
          alarmLevel:'中级',
          alarmMark:'进行中',
          action:'派发工单'
        }, {
          date: '2016-05-08',
          alarmName: '告警1',
          alarmDetail:'详情',
          alarmStaff:'王工',
          alarmLevel:'中级',
          alarmMark:'进行中',
          action:'派发工单'
        }, {
          date: '2016-05-06',
          alarmName: '告警1',
          alarmDetail:'详情',
          alarmStaff:'王工',
          alarmLevel:'中级',
          alarmMark:'进行中',
          action:'派发工单'
        }, {
          date: '2016-05-07',
          alarmName: '告警1',
          alarmDetail:'详情',
          alarmStaff:'王工',
          alarmLevel:'中级',
          alarmMark:'进行中',
          action:'派发工单'
        }],
        multipleSelection: []
      }
    },
        methods: {
          toggleSelection(rows) {
            if (rows) {
              rows.forEach(row => {
                this.$refs.multipleTable.toggleRowSelection(row);
              });
            } else {
              this.$refs.multipleTable.clearSelection();
            }
          },
          handleSelectionChange(val) {
            this.multipleSelection = val;
          }
  }
}
</script>
<style scoped lang="css" src="../assets/AlarmList/index.css" />